fi.foyt.svg.svgdom.FNISVGPathParser = Class.create({
  initialize: function(){
    this.commands = {
      // moveto
      M: ['x', 'y'],
      // lineto
      L: ['x', 'y'],
      // horizontal lineto
      H: ['x'],
      // vertical lineto
      V: ['y'],
      // curveto
      C: ['x1', 'y1', 'x2', 'y2', 'x', 'y'],
      // smooth curveto
      S: ['x2', 'y2', 'x', 'y'],
      // quadratic Belzier curve
      Q: ['x1', 'y1', 'x', 'y'],
      // smooth quadratic Belzier curveto
      T: ['x', 'y'],
      // elliptical Arc
      A: ['rx', 'ry', 'x-axis-rotation', 'large-arc-flag', 'sweep-flag', 'x', 'y'],
      // closepath
      Z: []
    };
  }, 
  parsePath: function (element) {
    var path = element.getAttribute("d");
    if ((path == null) || (path.blank()))
      return new Array();
    
    var d = path.replace(/,/g, ' ');
    var tokens = d.split(" ");
    var segments = new Array();
    var segment = null;
    var tmp = true;
    var x = null;
    var y = null;
    
    for (var i = 0; i < tokens.length; i++) {
      var token = tokens[i];
      // command 
      
      if (token.charAt(0).search("[a-zA-Z]") == 0) {
        var isAbsolute = token.charAt(0).search("[A-Z]") == 0;
        var command = isAbsolute ? token.charAt(0) : token.charAt(0).toLowerCase();
        segment = new FNISVGPathElementSegment(command, isAbsolute);
        segments.push(segment);        
        pIndex = 0;
        
        if (token.length > 1) {
          x = new Number(token.substring(1));
          tmp = false;
        }
      } else {
        tmp = !tmp;
        if (tmp == true)
          y = new Number(token);
        else 
          x = new Number(token);
      }
       
    if ((x != null) && (y != null)) {
      segment.addParameter(x, y);
    x = null;
      y = null;   
    } 
  }
    
    return segments;
  }
});